package practice.test3.studentRecord.plan1;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class ScoreDriver {

    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {

        //获取job信息
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);

        //加载驱动类
        job.setJarByClass(ScoreDriver.class);

        //关联Map类
        job.setMapperClass(ScoreMapper.class);

        job.setReducerClass(ScoreReducer.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Text.class);

        //设置输出类型
        job.setOutputKeyClass(NullWritable.class);
        job.setOutputValueClass(StuBean.class);


        //设置输入输出路径
        FileInputFormat.setInputPaths(job,new Path("F:\\test\\StudentInput"));
        FileOutputFormat.setOutputPath(job,new Path("F:\\test\\output"));

        //提交
        boolean b = job.waitForCompletion(true);
        System.exit(b ? 0 : 1);


    }
}
